Python Debugging Handbook by Zimmerman HL

Python Debugging Handbook by Zimmerman HL
Author: Zimmerman, HL [Zimmerman, HL]
Language: eng
Format: epub
Published: 2020-02-05

Runtime


The challenge with debugging runtime errors is a line (or suite) of code runs as expected several times, and then suddenly halts with an error. As a program runs, variable values change. Another example of a RunTime error is when a program takes too long to run.

While general RunTime errors are flagged as a “RunTimeError” by the Python Interpreter, what I am referring to as “Runtime” is the overall kind of error. The actual Traceback message displayed in the Console may vary, as shown in Chapter 7 in Examples 5 and Examples 7-12.

To research a runtime error, we need to look at the values at the moment the error occurred When looking at values, you may have a critical variable that must be a certain value for your code to function. Assert statements halt the program and warn you when values are outside the parameters you require.

Another example of a Runtime error is a chunk of code that takes too long to run. In this case, the function “timeit” times program execution.

• Debug Mode

• Variable Explorer

• Interactive Mode

• Print Statements

Chapter 7 looks at these kinds of errors in Examples 1, 4, 6, 14, 15, and 17.